from django.db import models
from myutils.base_model import BaseModel


class Role(BaseModel):
    """
    角色
    """
    name = models.CharField(max_length=30)

    class Meta:
        db_table = 'role'

    def __str__(self):
        return self.name


class User(BaseModel):
    username = models.CharField(max_length=30)
    password = models.CharField(max_length=256)
    phone = models.CharField(max_length=11, null=True, blank=True)
    email = models.EmailField(max_length=30, null=True, blank=True)
    status = models.BooleanField(default=False)
    role = models.ForeignKey(Role, on_delete=models.CASCADE)

    class Meta:
        db_table = 'user'

    def __str__(self):
        return self.username
